package com.zty.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @Author ZTY
 * @Description
 * @Date 17:01 2023-12-23
 **/

@Data
@Configuration
@ConfigurationProperties("discovery")
public class DiscoveryConfig {
    private String serverHost;
    private Integer serverPort;
    private String serviceId;
    private String schema;

    public String getServerAddress(){
        return "%s:%s".formatted(serverHost,serverPort);
    }

    /**
     * 构建定时任务，定时给Meta发送心跳包
     * @return
     */
    @Bean
    public ScheduledExecutorService scheduledExecutorService(){
        return Executors.newScheduledThreadPool(20);
    }
}
